import { selectMonitorhcDispose } from '@/services/api/api-monitorhc-dispose';
import { DrawerForm } from '@ant-design/pro-components';
import { Button, Descriptions, Typography } from 'antd';
import { useState } from 'react';

interface DetailMonitorDisposeContentProps {
  data: MonitorhcData.RecordPage;
  onRefurbish: () => void;
}
const DetailMonitorDisposeContent: React.FC<DetailMonitorDisposeContentProps> = ({
  data,
  onRefurbish,
}) => {
  // 定义一个状态来跟踪所选项
  const [disposeContent, setDisposeContentState] = useState<MonitorhcData.DisposeSelect>();

  /**
   * 根据key加载组织详情
   * @param key
   */
  const loadDisposeData = async () => {
    const res = await selectMonitorhcDispose({
      includeRecordId: data.id,
    });

    setDisposeContentState(res.data);
  };

  const container = () => {
    let scheme = '';
    if (disposeContent?.scheme == 1) {
      scheme = '不需要处理';
    } else if (disposeContent?.scheme == 2) {
      scheme = '下架不再发稿';
    } else if (disposeContent?.scheme == 3) {
      scheme = '下架修改重新发稿';
    } else if (disposeContent?.scheme == 4) {
      scheme = '其他方案';
    }

    return (
      <>
        <Descriptions title="处置人">
          <Descriptions.Item label="单位">{disposeContent?.organizationName}</Descriptions.Item>
          <Descriptions.Item label="姓名">{disposeContent?.accountName}</Descriptions.Item>
          <Descriptions.Item label="处置方案">{scheme}</Descriptions.Item>
        </Descriptions>
        <Typography.Paragraph>
          <blockquote>{disposeContent?.content}</blockquote>
        </Typography.Paragraph>
      </>
    );
  };

  return (
    <DrawerForm
      title="处置"
      trigger={<Button type="primary">处置方案</Button>}
      autoFocusFirstInput
      drawerProps={{
        // maskClosable: false,
        destroyOnClose: true,
        width: '100%',
      }}
      submitter={false}
      onVisibleChange={(open) => {
        if (open) {
          loadDisposeData();
        } else {
        }
      }}
    >
      {disposeContent && container()}
    </DrawerForm>
  );
};
export default DetailMonitorDisposeContent;
